<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@page import="aplicacao.classesBasicas.*"%>
<%@page import="aplicacao.repositorios.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gerenciador de Exercicios</title>
</head>
<body>
<h1>Exercicios</h1>
	<table border="1">
		<tr>
			<td>Nome</td>
			<td>Maquina</td>
			<td>Video</td>
		</tr>
		<% for (Exercicio exercicio : CadastroExercicios.listarExercicios()) { 
			Maquina maquina = CadastroMaquinas.consultarMaquina(exercicio.getId_maquina());
		%>
			<tr>
				<td> <%= exercicio.getNome() %> </td>
				<td> <%= maquina.getNome() %> </td>
				<td> <%= exercicio.getLinkVideo() %> </td>
				<td>
					<a href="removerExercicio?exercicio.id=<%= exercicio.getId() %>">Remover</a>
				</td>
			</tr>	
		<% } %>
		
	</table>
	
<h4>Cadastrar Novo Exercicio:</h4>
<form action="cadastrarExercicio" method="post">
<table>
<tr>
<td>
	Nome
</td>
	<td>
		<input type="text" name="exercicio.nome">
	</td>
</tr>
<tr>
<td>
	Maquina
</td>
	<td>
		<select name="exercicio.id_maquina">
		<%for (Maquina maquina : CadastroMaquinas.listarMaquinas()){ %>
			<option value="<%= maquina.getId()%>"><%= maquina.getNome() %></option>
		<%}%>
		</select>
	</td>
</tr>
<tr>
<td>
	Video
</td>
	<td>
		<input type="text" name="exercicio.linkVideo">
	</td>
</tr>
<tr>
<td><input type="submit" value="Cadastrar"></td>
</tr>
</table>

</form>
<a href="painel.jsp">Voltar</a>
</body>
</html>